package cn.msqweb.util;

import cn.msqweb.constant.HttpConstants;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

public class ResponseUtils {
    public static void weter(HttpServletResponse response, String jsonStr){
        response.setContentType(HttpConstants.APPLICATION_JSON);
        response.setCharacterEncoding(HttpConstants.UTF_8);
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        writer.write(jsonStr);
        writer.flush();
        writer.close();
    }
}
